//
//  DataBaseTool.swift
//  MySport
//
//  Created by lanou3g on 16/3/1.
//  Copyright © 2016年 ccsobj. All rights reserved.
//

import UIKit

import FMDB

class DataBaseTool: NSObject {
    static let shareInstance = DataBaseTool()
    
    private let db : FMDatabase
    
    //    private var community :Table!
    //    private var message : Table!
    
    private override init() {
        let doc = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true).last
        let path = doc! + "/MySport.sqlite"
        db = FMDatabase(path:path)
        if db.open(){
            
        }
    }
    
    
    enum DataType{
        case Int
        case String
        case Double
    }
    
    private func createTable(name:String){
        
        let pro1 = "userid" + "text" + "NOT NULL,"
        let pro2 = "uuid" + "text" + "NOT NULL,"
        let pro3 = "image" + "text" + "NOT NULL,"
        let pro4 = "content" + "text" + "NOT NULL,"
        let pro5 = "createTime" + "integer" + "NOT NULL,"
        let pro6 = "commentCount" + "integer" + "NOT NULL,"
        let pro7 = "praiseCount" + "integer" + "NOT NULL,"
        let pro8 = "lat" + "integer" + "NOT NULL,"
        let pro9 = "lon" + "integer" + "NOT NULL,"
        let pro10 = "adcode" + "text" + "NOT NULL,"
        
        let sql = "CREATE TABLE IF NOT EXISTS " + name + pro1 + pro2 + pro3 + pro4 + pro5 + pro6 + pro7 + pro8 + pro9 + pro10 + ");"
    }
    
    private func subpropertySqls(pults:[(String,DataType)]){
        
    }
    private func stringWithDataType(type:DataType)->String{
        switch type{
        case .Int : return "integer" + "NOT NULL,"
        case .String : return "text" + "NOT NULL,"
        case .Double : return "float" + "NOT NULL,"
        }
    
    }
    
}
